<template>
  <!-- 头部 -->
  <div class="header wrap">
    <!-- 左边logo -->
    <h1>
      <img src="../assets/img/indexLogo.6f8ac4f0.png" alt="" />
    </h1>
    <!-- 中间导航 -->
    <ul class="cenvar">
      <li @click="$router.push('/home').catch(() => {})" :class="$route.path == '/home' ? 'current' : ''">首页</li>
      <li :class="$route.path == '/goods' ? 'current' : ''" @click="$router.push('/goods').catch(() => {})">
        全部商品
      </li>
      <li :class="$route.path == '/user' ? 'current' : ''" @click="$router.push('/user').catch(() => {})">个人中心</li>
      <li :class="$route.path == '/order' ? 'current' : ''" @click="$router.push('/order').catch(() => {})">
        我的订单
      </li>
      <li :class="$route.path == '/free' ? 'current' : ''" @click="$router.push('/free').catch(() => {})">专属福利</li>
    </ul>

    <!-- 右边搜索 -->
    <div class="search">
      <input type="text" v-model="keyword" placeholder="请输入关键字" @keyup.13="send" />
      <span>
        <img src="../assets/img/search.png" alt="" />
      </span>
    </div>
  </div>
</template>
 
<script>
export default {
  data() {
    return {
      keyword: ''
    }
  },
  methods: {
    send() {
      this.$router.push(`/goods?keyword=${this.keyword}`)
    }
  }
}
</script>
 
<style lang = "less" scoped>
.header {
  height: 118px;

  display: flex;
  justify-content: space-between;
  align-items: center;
  /*   background: pink; */
  .cenvar {
    display: flex;
    justify-content: space-between;

    li {
      padding: 0 10px;
      margin-right: 20px;
      cursor: pointer;
      font-weight: 500;
    }
    .current {
      color: blue;
      font-weight: 700;
    }
  }
  .search {
    display: flex;
    input {
      width: 214px;
      height: 40px;
      border: 1px solid #dedede;
      border-radius: 20px 0px 0px 20px;
      box-sizing: border-box;
      outline: none;
      padding-left: 20px;
    }
    span {
      /* span是行内块，不能设置宽高 ，用弹性布局就可以忽略这些 */
      width: 50px;
      height: 40px;
      line-height: 40px;
      background: #0a328e;
      border-radius: 0px 20px 20px 0px;
      box-sizing: border-box;
      cursor: pointer;
      text-align: center;
      img {
        width: 15px;
        height: 15px;
      }
    }
  }
}
</style>